package eqsolver.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import eqsolver.*;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

public class EquationMenu extends JMenu {

	//private IEquation linearEquation = new ModelLinearEquation();
	//private IEquation quadraticEquation = new ModelQuadraticEquation();
	private float[] param = { 0, 0, 0, 0, 0 };
	private ProxyEquation equation; // = new ProxyEquation(new
									// Equation(param.length, param));

	public EquationMenu(ProxyEquation equation) {

		super("Equations");
		this.equation = equation;
		setLinear();

		JMenuItem linearMenu = new JMenuItem("Linear");
		linearMenu.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// ProxyEquation equation = new ProxyEquation(new Equation(2,
				// param))
				setLinear();
			}
		});
		this.add(linearMenu);

		JMenuItem quadraticMenu = new JMenuItem("Quadratic");
		quadraticMenu.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				setQuadratic();
			}
		});

		this.add(quadraticMenu);
	}

	public void control1() {
		ModelLinearEquation linearEquation = new ModelLinearEquation();
		linearEquation.setEquation(2, new float[] { 0, 0 });
		System.out.println(linearEquation.getParam()[0] + " "
				+ linearEquation.getParam()[1]);
		setLinear();
	}

	public void control2() {
		ModelQuadraticEquation quadraticEquation = new ModelQuadraticEquation();
		System.out.println(quadraticEquation.getParam()[0] + " "
				+ quadraticEquation.getParam()[1] + " "
				+ quadraticEquation.getParam()[2]);
	}

	public void setLinear() {

//		IEquation linearEquation = new ModelLinearEquation();
//		linearEquation.setEquation(2, equation.getParam());
		equation.setEquation(2, equation.getParam());
		
	}

	public void setQuadratic() {

//		IEquation quadraticEquation = new ModelQuadraticEquation();
//		quadraticEquation.setEquation(3, equation.getParam());
		equation.setEquation(3, equation.getParam());

	}

}
